package com.zhihao.takeaway.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhihao.takeaway.common.utils.EasyUITable;
import com.zhihao.takeaway.entity.AddressBook;
import com.zhihao.takeaway.mapper.AddressBookMapper;
import com.zhihao.takeaway.service.AddressBookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AddressBookServiceImpl extends ServiceImpl<AddressBookMapper, AddressBook>
        implements AddressBookService {

    @Autowired
    private AddressBookMapper addressBookMapper;

    @Override
    public EasyUITable getAddressBookByUserId(String userId) {
        QueryWrapper<AddressBook> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(AddressBook::getUserId,userId);
        List<AddressBook> list = addressBookMapper.selectList(queryWrapper);
        return new EasyUITable(list.size(),list);
    }
}
